package com.next

import grails.transaction.Transactional
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked

@CompileStatic
@TypeChecked
@Transactional
class CompanyService
{

    def initData()
    {
        if (Company.count() < 1)
        {
            /** ****************************************************************************************/
            println 'init company'
            def company = new Company(name: '默认公司')
            company.save()

            /** ****************************************************************************************/
            println 'init department'
            def department = new Department(name: '销售部', company: company)
            department.save()

            department = new Department(name: '市场部', company: company)
            department.save()

            department = new Department(name: '客服部', company: company)
            department.save()

            department = new Department(name: '财务部', company: company)
            department.save()

            /** ****************************************************************************************/
            println 'init job'
            def job = new Job(name: '销售经理', company: company)
            job.save()

            job = new Job(name: '销售代表', company: company)
            job.save()

            /** ****************************************************************************************/
            println 'init position'
            def position = new Position(name: "销售经理")
            position.save()

            position = new Position(name: "销售员")
            position.save()
        }

    }
}
